<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0"/>
		<title>设备事件</title>
	</head>
	<body>
		<p id="msg"></p>
	</body>
	<script type="text/javascript">
		var msg = document.querySelector("#msg");
		//监听判断手机横竖屏切换事件
		window.addEventListener("orientationchange",function(){
			if(window.orientation == 0){
				alert("肖像模式");
			}else if(window.orientation == 90){
				alert("左切换的横屏模式");
			}else if(window.orientation == -90){
				alert("右切换");
			}
			msg.innerHTML = window.orientation;
		},false);
	</script>
</html>
